package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TowerGoods;
import com.ruoyi.system.service.ITowerGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 塔商品实体Controller
 * 
 * @author ruoyi
 * @date 2024-09-01
 */
@RestController
@RequestMapping("/system/tagoods")
public class TowerGoodsController extends BaseController
{
    @Autowired
    private ITowerGoodsService towerGoodsService;

    /**
     * 查询塔商品实体列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:list')")
    @GetMapping("/list")
    public TableDataInfo list(TowerGoods towerGoods)
    {
        startPage();
        List<TowerGoods> list = towerGoodsService.selectTowerGoodsList(towerGoods);
        return getDataTable(list);
    }

    /**
     * 导出塔商品实体列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:export')")
    @Log(title = "塔商品实体", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TowerGoods towerGoods)
    {
        List<TowerGoods> list = towerGoodsService.selectTowerGoodsList(towerGoods);
        ExcelUtil<TowerGoods> util = new ExcelUtil<TowerGoods>(TowerGoods.class);
        util.exportExcel(response, list, "塔商品实体数据");
    }

    /**
     * 获取塔商品实体详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(towerGoodsService.selectTowerGoodsById(id));
    }

    /**
     * 新增塔商品实体
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:add')")
    @Log(title = "塔商品实体", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TowerGoods towerGoods)
    {
        return toAjax(towerGoodsService.insertTowerGoods(towerGoods));
    }

    /**
     * 修改塔商品实体
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:edit')")
    @Log(title = "塔商品实体", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TowerGoods towerGoods)
    {
        return toAjax(towerGoodsService.updateTowerGoods(towerGoods));
    }

    /**
     * 删除塔商品实体
     */
    @PreAuthorize("@ss.hasPermi('system:tagoods:remove')")
    @Log(title = "塔商品实体", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(towerGoodsService.deleteTowerGoodsByIds(ids));
    }
}
